<template>
  <div class="ant-pro-page-header-wrap">
    <div class="ant-pro-page-header-wrap-page-header-warp">
      <div class="ant-pro-grid-content">
        <div class="ant-page-header">
          <div class="store-wrap">
            <provider-info-item :providerInfo="storeInfo" />
          </div>
        </div>
      </div>
    </div>
    <div class="ant-pro-page-header-wrap-children-content">
      <stat-info :statInfo="statInfo" />
    </div>
    <div class="ant-pro-page-header-wrap-children-content">
      <a-card :bordered="false">
        <div class="ant-descriptions-title">订单列表</div>
        <div class="table-page-search-wrapper">
          <a-form layout="inline" :form="orderForm">
            <a-row :gutter="24">
              <a-col :md="4" :sm="24">
                <a-form-item>
                  <a-range-picker v-model="orderDateRange">
                    <a-icon slot="suffixIcon" type="calendar" />
                  </a-range-picker>
                </a-form-item>
              </a-col>
              <a-col :md="4" :sm="24">
                <a-form-item>
                  <a-input placeholder="请输入订单编号" v-model="orderParams.search" />
                </a-form-item>
              </a-col>
              <a-col :md="4" :sm="24">
                <span class="table-page-search-submitButtons">
                  <a-button type="primary" @click="$refs.orderTable.refresh()" icon="search">查询</a-button>
                </span>
              </a-col>
            </a-row>
          </a-form>
        </div>
        <clothes-order-table :data="getStoreDetail" ref="orderTable" v-if="$route.query.type === 'clothes'" />
        <service-order-table :data="getStoreDetail" ref="orderTable" v-else />
      </a-card>
    </div>
    <div class="ant-pro-page-header-wrap-children-content">
      <a-card :bordered="false">
        <div class="ant-descriptions-title">乐管家列表</div>
        <div class="table-page-search-wrapper">
          <a-form layout="inline">
            <a-row :gutter="24">
              <a-col :md="4" :sm="24">
                <a-form-item>
                  <a-range-picker @change="onChange">
                    <a-icon slot="suffixIcon" type="calendar" />
                  </a-range-picker>
                </a-form-item>
              </a-col>
              <a-col :md="4" :sm="24">
                <a-form-item>
                  <a-input placeholder="请输入订单编号" v-model="queryParam.search" />
                </a-form-item>
              </a-col>
              <a-col :md="4" :sm="24">
                <span class="table-page-search-submitButtons">
                  <a-button type="primary" @click="$refs.table.refresh()" icon="search">查询</a-button>
                </span>
              </a-col>
            </a-row>
          </a-form>
        </div>
        <a-table
          ref="table"
          size="default"
          rowKey="id"
          :columns="columns"
          :dataSource="earningList"
          :pagination="{ 'show-total': total => `共 ${total} 条` }"
        >
          <template slot="img_url" slot-scope="text">
            <a-avatar shape="square" :size="64" icon="skin" :src="text" />
          </template>

          <template v-slot:pay_type="{ pay_type }">
            <span>{{ pay_type | payTypeFilter }}</span>
          </template>
        </a-table>
      </a-card>
    </div>
  </div>
</template>

<script>
import { managerDetail } from '@/api/managerProvider'
import ProviderInfoItem from '@/components/ProviderInfoItem'
import StatInfo from '@/components/stat-info/stat-info'
export default {
  name: 'ProviderStat',
  components: {
    ProviderInfoItem,
    StatInfo
  },
  data () {
    return {
      queryParam: {
        search: '',
        atime: '',
        etime: '',
        type: 0
      },
      orderDateRange: [],
      orderParams: {},
      earningList: [],
      storeInfo: {},
      statInfo: {},
      orderForm: this.$form.createForm(this)
    }
  },
  created () {
    this.getStoreInfo()
  },
  methods: {
    getStoreInfo () {
      const params = this.$route.query
      managerDetail(params).then(res => {
        this.storeInfo = res.data
      })
    }
  }
}
</script>
